<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>猜数字</title>
</head>
<body>
        <script>
          var i = 0;
          var z =Math.floor(Math.random()*10);
          console.log(z);
          while (true) {
              var inputV = prompt('请输入一个数');
              if (inputV == z) {
                  alert('嗯，猜对了');
                  break
              }
              console.log(i);
              i++
          }
        </script>
</body>
</html>